﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Manager_Lib_Controls_StateFlow_LoanStatus : System.Web.UI.UserControl {

	#region Overrides
	protected override void Render(HtmlTextWriter writer) {
		ScriptManager sm = ScriptManager.GetCurrent(Page);
		if (sm == null || !sm.IsInAsyncPostBack) {
			base.Render(writer);
			return;
		}
		if (NamingContainer == null) throw new Exception("No naming container found.");
		StringBuilder sb = new StringBuilder();
		System.IO.StringWriter sw = new System.IO.StringWriter(sb);
		HtmlTextWriter w = new HtmlTextWriter(sw);
		base.Render(w);
		w.Flush();
		string html = sb.ToString();
		string script = Regex.Match(html, @"<script>[\s\S]+[<]/script>", RegexOptions.IgnoreCase).Value;
		ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Script_"+WSMethod, script, false);
		writer.Write(sb.ToString());
	}
	#endregion

	[Bindable(true)]
	public int StatusFromID { 
		set { 
			dsNextStates.StateFromID = value;
			//if (value == 0) sel.DataSourceID = dsState.ID;
		}
	}
	string _dataSrc = "XmlLoanInfo";
	public string dataSrc {
		get { return _dataSrc; }
		set {
			_dataSrc = value;
			sel.Attributes["dataSrc"] = "#"+value;
		}
	}
	string _wsMethod = "";
	public string WSMethod {
		get { return _wsMethod; }
		set {
			_wsMethod = value;
			sel.Attributes["WSMethod"] = value;
			sel.Attributes["onchange"] = sel.Attributes["onchange"].Replace("UF_Status", "UF_" + value);
			sel.ID += value;
		}
	}
	public string Width { set { sel.Style[HtmlTextWriterStyle.Width] = value; } }
	int _rows = -1;
	public int Rows { set { _rows = sel.Rows = value; } }
	public string DataFld { set { sel.Attributes["dataFld"] = value; } }
	public string IDName { set { sel.Attributes["IDName"] = value; } }

	protected void Page_Load(object sender, EventArgs e) {
	}
	protected void sel_DataBound(object sender, EventArgs e) {
		if (_rows >= 0) return;
		((ListBox)sender).Rows = ((ListBox)sender).Items.Count;
	}
}
